package org.bluedream.comm.utils.excel;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @ClassName ExcelAnnotationAnalysis
 * @Description TODO
 * @Author foxsand
 * @Data 2021-08-26 17:03
 * @Version
 */
@Data
@AllArgsConstructor
public class ExcelAnnotationAnalysis implements Comparable<ExcelAnnotationAnalysis>{
    private String fieldName; //属性名称
    private Class<?> fieldType; //属性类型
    private ExcelType excelType;
    private String excelFieldName;
    private boolean isRequired;
    private int fieldSort;

    /**
     * 用于文件导出
     * @param fieldName
     * @param fieldType
     * @param excelType
     * @param excelFieldName
     * @param fieldSort
     */
    public ExcelAnnotationAnalysis(String fieldName, Class<?> fieldType, ExcelType excelType, String excelFieldName, int fieldSort) {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.excelType = excelType;
        this.excelFieldName = excelFieldName;
        this.fieldSort = fieldSort;
    }

    /**
     * 用于文件导入
     * @param fieldName
     * @param fieldType
     * @param excelType
     * @param excelFieldName
     * @param isRequired
     */
    public ExcelAnnotationAnalysis(String fieldName, Class<?> fieldType, ExcelType excelType, String excelFieldName, boolean isRequired) {
        this.fieldName = fieldName;
        this.fieldType = fieldType;
        this.excelType = excelType;
        this.excelFieldName = excelFieldName;
        this.isRequired = isRequired;
    }

    @Override
    public int compareTo(ExcelAnnotationAnalysis annotationAnalysis) {
        //        return this.age-o.age; 升序排序
        //        return o.age-this.age; 降序排序
        return this.fieldSort - annotationAnalysis.fieldSort;
    }
}
